package com.king.juc.fivetest;

/**
 * 案例3
 *
 * @author king
 * @date 2020/11/28 20:42
 */
public final class SingletonThree {
    private SingletonThree() {
    }

    private static SingletonThree INSTANCE = null;

    // 分析这里的线程安全, 并说明有什么缺点
    // 答: 锁的范围太大, 影响性能
    public static synchronized SingletonThree getInstance() {
        if (INSTANCE != null) {
            return INSTANCE;
        }
        INSTANCE = new SingletonThree();
        return INSTANCE;
    }
}
